package com.wx.javacode.encap;

/**
 * ClassName:Account
 * Package :com.wx.javacode.encap
 * Description :
 *
 * @Author : coder_mu
 * @Create : 2023/5/1 - 16:45
 */
public class Account {
    public String name;
    private double money;
    private String password;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() >= 2 && name.length() <= 4) {
            this.name = name;
        } else if (name.length() > 4) {
            System.out.println("名字过长");
        } else {
            if (name.length() > 0) {
                System.out.println("名字过短");
            } else {
                System.out.println("名字不能为空");
            }
        }
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        if (money > 20) {
            this.money = money;
        } else {
            System.out.println("余额不足");
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if (password.length() == 6) {
            this.password = password;
        } else {
            System.out.println("密码必须是六位，给你设置的默认密码为123456");
            this.password = "123456";
        }
    }

    public void info() {
        System.out.println("姓名" + name);
        System.out.println("余额" + money);
        System.out.println("密码" + password);
    }
}
